import { createBrowserRouter, Navigate } from "react-router-dom";
import PageLayout from "../layout";
import PageHome from "../pages/home";
import PageUser from "../pages/user";
import PageMallGoods from "../pages/mall/goods";
import PageMallOrder from "../pages/mall/order";

const router = createBrowserRouter([
  {
    path: "/",
    Component: PageLayout,
    children: [
      {
        path: "",
        element: <Navigate to="/home" replace />,
      },
      {
        path: "/home",
        Component: PageHome,
      },
      {
        path: "/user",
        Component: PageUser,
      },
      {
        path: "/mall",
        children: [
          {
            path: "goods",
            Component: PageMallGoods,
          },
          {
            path: "order",
            Component: PageMallOrder,
          },
        ],
      },
      {
        path: "*",
        element: <div>404</div>,
      },
    ],
  },
]);

export default router;
